package Demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Test2 {

    public static void main(String[] args) {
        //指定线程数量线程池  注意：参数不是初始值是最大值
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        //获取执行了几次
        ThreadPoolExecutor p = (ThreadPoolExecutor) executorService;
        int poolSize = p.getPoolSize();
        System.out.println(poolSize);

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行");
        });
        System.out.println(p.getPoolSize());
    }
}
